package com.movie2.config;

import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

@Component
public class AlipayConfig {
    // 商户appid
    public static String APPID = "2021000120613404";
    // 私钥 pkcs8格式的
    public static String RSA_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCiobl00sjNJKr/ezUlvzkZxqWGE8WYZSMVYKC95V6V7mYGwf0vqg4agh+oDl+yBshMfS6He/xLUaMFVyzLPfl2Ei3mVKpvKL0rVf84lCBCuUgaHDJrW7Jb6oCQadcNQuy7HwoQ3+yUyb9E+tFbXSjGmAkp2FyNF7RmP0mDYqtOsyneKJOMn6qVqQjgodrq/E2UDOBRxJPV54JdS/KmNg/6RGQhf0MdkbqOtWMg/X8mxrOGaAQzRrWyw80Q07jOcGXq0bUZTbEoTQZE9RBxw+1hfeuoTTLmha5fFXn31tLYqTDbRaqU09xpftNDP3RAa1Bq0UB9x1nqjo2NpwNlYzeRAgMBAAECggEASykS3LrNsoFPxeLbHSbS7OaxeNWKbHPRUv/lSd3HaONUo6rjqDOfcQDSQIjkERKxXyg7aMIUR3rjLIStXwC1WavtKpXWbqkVRAHqgetzPWMDv41of9VRCMnHwPYpPSfA4Hnn3QSgAeN7UhXYy7CyN5XsJjqoC0z5QofdIatoIGZQQHI+7VFcg+Q+NMoKel0EvQ118pQibWT+F7m8ORqlmtmUy/Ht1i7O7wOqtWq01BfDFdyWlziFL49d64J+a/7akIwRTMa/XrO6wLGJNHkdhuFR59fduVt9t32MVwSkyNXa+MGFHEAzzxRw9VwQl7aaOiQRi9WHva3tym0FwaAIQQKBgQDQAm1TUsYPUvc97StRWBgTSt+/UFUfkMxWH6qhQveUEDspToxBO/CUqTwGMsNNOZte7C7xaw13h8B4KsZeLFpL//HRro+xGQ7K+VdNCj1Nc560oWjOKFBhzlUZpWY44hNsainrCHSfpgsKhwBZXkylxPBgtZikZPm96mUyIDyWawKBgQDIJyvoMQ6rtv2Btmb91rdWVGHYYlBOzAIOpumABQ/5Xas+kFtTfqpvni7myyfaCKaarJ4fu4Ten66yHnES1golJaVQ4fOV/TsKksgCGkl7R9AhLTdhfK0xW6TkIzwHy6Al9UNBQfKkoU2lwwiOElaAlWTmaMgrsKxhWbupqF1Q8wKBgQDI819MnO2shjlGwSYVCqcPlEj+GQxzVz6ggS0lZ32os9mDuVdz+gUciTXswwO8SkfYdxGOtx4meKYvMRu8hNqjC1tBd4Nn0s5gtmtpiNfaSDVtSXXnnDizlFLQWOKdV4LuPM3MOrn4Nb/65psmuxwPFWgn9afGQaqnl5c1ysDdiwKBgA/hi8pQmilly5ePMXzSnJls+JaCtnyKE1+2PrC5thrDI+NC8PwfAMb6dh454F+ccBu1tpYt+szvPp1DbRVhhkyMQCG6y+kKvrSIEPaZv1rYx9raC5rgmZ1g+CRh51F3Bq38V+nFocsOQWr1nqgnLFXnhKoDhl5xFjxjMlCz2zOhAoGBALpidxRwba+4x/2bwt6RKKa3q23ALE+tmM5JbUaHVlA3MB+Mvh4iV4Kl7cWiZjssih0rT6V8jDaSGJEVHkifuuTuXj3Kh+ybY6pDCotniXEprafrKStjORgUgSfDmhrYFAjf7sxkoXKpMEr+5QU1tPshLVaPne4tKJMkcHeZFRdy";
    // 写个内网试试
    public static String notify_url = "http://localhost:8888/pay";
    // 写个内网试试
    public static String return_url = "http://localhost:8080/personal_center/shopping_cart";
    // 请求网关地址
    public static String URL = "https://openapi.alipaydev.com/gateway.do";
    // 编码
    public static String CHARSET = "UTF-8";
    // 返回格式
    public static String FORMAT = "json";
    // 支付宝公钥
    public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj2o/YqXSujfpCmS+y8FvdQwUEMCEudWB2CunkkoZ68wm/7abRFr8Ba/QyuP6oXp1gBpnEPZaeQ1ptwcsjxL6HGdG29Zyqz9i8Fx2CipmPhms6Fr7xK+70iHcrhiaZg+aoAjTUf6n08rkI7ajkGy7C/gyEy01jeXpdqA3GMavCVeW1kOBL7S8dG9Kb0GK2hlcUTOYBBsVt+Y0ON2Cfae7qc+WL09w4nuS2izZkhwoLqLtJgAFSvAitMfn+41khLTQouLAON1sIVvnvNLJby6yNpXBSUiaecYZQUaIUIxW8vkj+DIKffBlsjQPmpMUlIcGSULq9h/5oAEUELfKYiEolQIDAQAB";
    // 日志记录目录
    public static String log_path = "/log";
    // RSA2
    public static String SIGNTYPE = "RSA2";

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     *
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        String log_path = "E:\\logs\\";
        //写入路径
        File file = new File(log_path);
        //判断路径是否存在，不存在就创建
        if (!file.exists()) {
            System.out.println("目标文件所在路径不存在，准备创建。。。");
            file.mkdirs();
            if (!file.mkdirs()) {
                System.out.println("创建成功");
            } else {
                System.out.println("创建失败，请重试");
            }
        } else {
            System.out.println("文件路径已存在");
        }

        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log" + System.currentTimeMillis() + ".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
